#include<bits/stdc++.h>
using namespace std;
const int N = 1005;

string s1,s2;
int dp[N][N];

int main(){
    cin>>s1;
    int len = s1.length();
    s2 = s1;
    for(int i=0;i<len;i++){
        if(i>=len-1-i) break;
        swap(s2[i],s2[len-1-i]);
    }
    s1 = " "+s1;
    s2 = " "+s2;
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=len;i++){
        for(int j=1;j<=len;j++){
            if(s1[i]==s2[j]) dp[i][j] = dp[i-1][j-1]+1;
            else dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
        }
    }
    cout<<len-dp[len][len]<<endl;
    return 0;
}